/* Funciones correspondientes a la pantalla de Login */

function login() {	
	var a_user = $("#user").val();
	var a_password = $("#password").val();
	var serviceURL = 'http://10.0.2.2:8080/Phama/pharmaws';
	$.mobile.showPageLoadingMsg(); 
	$.soap({
	    url: serviceURL,
	    appendMethodToURL: false, 
	    method: 'login',
	    namespaceQualifier: 'ns2',
	    namespaceUrl: 'http://ws.phama.it.eps.upo.org/',
	    params: {
	        user: a_user,
	        password: a_password
	    },
	    success: function (soapResponse) {
	    	var xmlDoc = $.parseXML(soapResponse);
	        xml = $(xmlDoc);
	        $.mobile.hidePageLoadingMsg();
	        
	        var usuario = xml.find("return").find("usuario").text();
	    	if (usuario == '') {
	    		$('#dlg_aviso_login').popup('open');
	    	} else {
	    		logged = true;
	    		$.mobile.changePage('#menu', {transition : "slide"});
	    	}
	    },
	    error: function (SOAPResponse) {
	    	$.mobile.hidePageLoadingMsg();
	    	alert(SOAPResponse);
	    }
	});
}
